module MemReadWriteChooser(reset, address, icode, readEnable, writeEnable, readAddress, writeAddress);
input [31:0] address;
input [3:0] icode;
input reset;

output reg readEnable;
output reg writeEnable;
output reg [31:0] readAddress;
output reg [31:0] writeAddress;


always @(*) begin
	if(!reset) begin
		readAddress <= 0;
		writeAddress <= 0;
		readEnable <= 0;
		writeEnable <= 0;
	end else begin
		case (icode)
			default: begin
				readAddress <= 0;
				writeAddress <= 0;
				readEnable <= 0;
				writeEnable <= 0;
			end
			5,9,11: begin
				readAddress <= address;
				writeAddress <= 0;
				readEnable <= 1;
				writeEnable <= 0;
			end
			4,8,10: begin
				readAddress <= 0;
				writeAddress <= address;
				readEnable <= 0;
				writeEnable <= 1;
			end
		endcase
	end
end

endmodule
